﻿using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using System.Collections.Generic;
using Maxcoderz.GameObjects;

namespace Maxcoderz
{
    public static class Global
    {
        private static SpriteFont _font;
        private static SpriteBatch _spriteBatch;
        private static Texture2D _nullTexture;
        private static Texture2D _globalTexture;
        private static float[] _scales = {0.75f*0.5f,0.5f,1.25f*0.5f};
        private static Color[] _layerColors = { Color.Gray, Color.White, Color.DarkGray };
        private static Dictionary<string, Sprite> _sprites = new Dictionary<string, Sprite>();

        #region Properties
        public static SpriteFont Font
        {
            get { return _font; }
            set { _font = value; }
        }

        public static SpriteBatch SpriteBatch
        {
            get { return _spriteBatch; }
            set { _spriteBatch = value; }
        }

        public static Texture2D NullTexture
        {
            get { return _nullTexture; }
            set { _nullTexture = value; }
        }

        public static Texture2D GlobalTexture
        {
            get { return _globalTexture; }
            set { _globalTexture = value; }
        }

        public static float[] Scales
        {
            get { return _scales; }
        }

        public static Color[] LayerColors
        {
            get { return _layerColors; }
        }

        public static Dictionary<string, Sprite> Sprites
        {
            get { return _sprites; }
        }
        #endregion

        public static void DrawText(int x, int y, string text)
        {
            DrawText(x, y, text, 1f, Color.White);
        }

        public static void DrawText(int x, int y, string text, float size, Color color)
        {
            DrawText(x, y, text, size, color, true);
        }

        public static void DrawText(int x, int y, string text, float size, Color color, bool initSpriteBatch)
        {
            if (initSpriteBatch)
            {
                SpriteBatch.Begin();
            }
            SpriteBatch.DrawString(_font, text, new Vector2((float)x, (float)y), color, 0f, new Vector2(), size, SpriteEffects.None, 1f);
            if (initSpriteBatch)
            {
                SpriteBatch.End();
            }
        }
    }
}